from langgraph.checkpoint.sqlite import SqliteSaver
from langgraph.prebuilt import create_react_agent

from config.model_config import get_chat_openai_zhipu_flash_250414

llm = get_chat_openai_zhipu_flash_250414()

with SqliteSaver.from_conn_string("checkpoints202506111958.sqlite") as checkpointer:
    graph = create_react_agent(llm, "", checkpointer=checkpointer)
    # display(Image(graph.get_graph().draw_mermaid_png()))

    # 检索检查点的数据
    config = {"configurable": {"thread_id": "1"}}
    # 获取给定 thread_id 的所有检查点
    checkpoints = list(checkpointer.list(config))
    for checkpoint in checkpoints:
        print(checkpoint)

    for chunk in graph.stream({"messages": ["分别是什么问题"]}, config, stream_mode="values"):
        chunk["messages"][-1].pretty_print()
